package client;

import java.net.Socket;

import ui.INickPanel;
import ui.IReadingPanel;

public class Controller implements IController {
	
	private String nick;
	private IReadingPanel readingPanel;
	private SingleController singleController;
	private MultipleController multipleController;
	private INickPanel nickPanel; 
	
	/* (non-Javadoc)
	 * @see client.IControl#controll(java.net.Socket, javax.swing.JTextArea, client.INickPanel, java.io.BufferedReader)
	 */
	public Controller(String nick,IReadingPanel rP,SingleController sC,MultipleController mC,INickPanel nP) {
		
		this.nick=nick;
		this.readingPanel=rP;
		this.singleController=sC;
		this.multipleController=mC;
		this.nickPanel=nP;
	
	}
	
	@Override
	public void controll(Socket socket,String read){
		
		if(read.substring(0,1).equalsIgnoreCase("@")){
			
			singleController.singleControll(nick, read);
			
			return;
		}
			
			multipleController.multipleController(read,nickPanel,readingPanel);
		
				
		}

	public MultipleController getMultipleController() {
		return multipleController;
	}
	
	
	public INickPanel getNickPanel() {
		return nickPanel;
	}


}
	
